package GUI;

import javax.swing.table.AbstractTableModel;

import Verwaltung.Daten.Aktivitaet;
import Verwaltung.Daten.Interfaces.IAktivitaet;

/**
 * 
 * @author MaximumDataOverdrive
 * 
 */
public class StundenplanTableModel extends AbstractTableModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final String[] columnNames = { "Zeit", "Montag", "Dienstag",
			"Mittwoch", "Donnerstag", "Freitag" };

	private final Object[][] data = new Object[8][5];

	private final String[] zeiten = { "8:00-9:00", "9:00-10:00", "10:00-11:00",
			"11:00-12:00", "12:00-13:00", "13:00-14:00", "14:00-15:00",
			"15:00-16:00" };

	@Override
	public int getColumnCount() {
		return columnNames.length;
	}

	@Override
	public int getRowCount() {
		return zeiten.length;
	}

	@Override
	public String getColumnName(final int col) {
		return columnNames[col];
	}

	@Override
	public Object getValueAt(final int row, final int col) {

		if (col == 0) {

			return zeiten[row];
		}

		return data[row][col - 1];
	}

	@Override
	public Class getColumnClass(final int c) {

		if (c == 0) {
			return String.class;
		}
		return Aktivitaet.class;
	}

	/*
	 * Don't need to implement this method unless your table's editable.
	 */
	@Override
	public boolean isCellEditable(final int row, final int col) {
		// Note that the data/cell address is constant,
		// no matter where the cell appears onscreen.
		if (col == 0) {
			return false;
		} else {
			return true;
		}
	}

	public void setData(final int row, final int col, final IAktivitaet aktivi) {

		data[row][col] = aktivi;
	}
}
